package com.ity.teamanagement.utils;

import lombok.Data;

@Data
public class PageableDetails<T> {

    //当前页
    private Integer index;

    //每页条数
    private Integer size;

    //总条数
    private Integer total;

    //总页数(0~totalPages)
    private Integer totalPages;

    //偏移值
    private Integer offSet;

    //偏移值1
    private Integer offSet1;

    //偏移值2
    private Integer offSet2;

    //数据
    private T newFindList;

    public PageableDetails() {
    }

    public PageableDetails(Integer index, Integer size) {
        this.index = index;
        this.size = size;
    }

    public PageableDetails(Integer index, Integer size, Integer total) {
        this.index = index;
        this.size = size;
        this.total = total;
    }

    public PageableDetails(Integer index, Integer size, Integer total, Integer totalPages) {
        this.index = index;
        this.size = size;
        this.total = total;
        this.totalPages = totalPages;
    }

    public PageableDetails(Integer pageNumber, Integer pageSize, Integer total, T DataList) {
        this.index = pageNumber;
        this.size = pageSize;
        this.total = total;
        this.totalPages = this.returnPages(total, size);
        this.newFindList = DataList;
    }

    public PageableDetails(Integer index, Integer size, Integer total, Integer totalPages, T newFindList) {
        this.index = index;
        this.size = size;
        this.total = total;
        this.totalPages = totalPages;
        this.newFindList = newFindList;
    }

    public PageableDetails(Integer index, Integer size, Integer total, Integer totalPages, Integer offSet, T newFindList) {
        this.index = index;
        this.size = size;
        this.total = total;
        this.totalPages = totalPages;
        this.offSet = offSet;
        this.newFindList = newFindList;
    }

    public PageableDetails(Integer index, Integer size, Integer total, Integer totalPages, Integer offSet, Integer offSet1, T newFindList) {
        this.index = index;
        this.size = size;
        this.total = total;
        this.totalPages = totalPages;
        this.offSet = offSet;
        this.offSet1 = offSet1;
        this.newFindList = newFindList;
    }

    public PageableDetails(Integer index, Integer size, Integer total, Integer totalPages, Integer offSet, Integer offSet1, Integer offSet2, T newFindList) {
        this.index = index;
        this.size = size;
        this.total = total;
        this.totalPages = totalPages;
        this.offSet = offSet;
        this.offSet1 = offSet1;
        this.offSet2 = offSet2;
        this.newFindList = newFindList;
    }

    /**
     * 返回总页数
     *
     * @param total
     * @param pageSize
     * @return
     */
    protected int returnPages(int total, int pageSize) {
        //总页数
        return PageUtils.returnPages(total, pageSize);
    }
}

